﻿#ifndef BLOCK_H
#define BLOCK_H

/********************************************************
 * @ClassName:  Block
 * @Brief:      管理单个方块特性
 * @date        2021/12/28
 ********************************************************/
#include <QGraphicsObject>

class Block : public QGraphicsObject
{
public:
    Block(const QColor &brushColor = Qt::red, BlockType blockType = NormalBlock);

    QRectF boundingRect() const override;
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
    QPainterPath shape() const override;

    int type() const override {
        return m_blockType;
    }

    void setCoord(int x, int y);        //设置坐标
    QPoint coord();     //得到坐标

    BlockType blockType() const;

    void setBlockType(BlockType newBlockType);

    void moveToAxis(int x, int y);      //移动至坐标位置

    void setOpacity(double newOpacity);

private:
    QColor m_brushColor;
    BlockType m_blockType = NormalBlock;
    double m_opacity = 1;    // 透明度
};

#endif // BLOCK_H
